/* EzDataTableExtension */

var DataConverterForDataTable = {};

DataConverterForDataTable = {
    convertData: function (originalJson, convertor) {

        var dataTableData = {};
        dataTableData.aaData = [];
        dataTableData.aoColumns = [];

        for (var key in convertor) {
            var stitle = {};
            stitle["sTitle"] = key;
            dataTableData.aoColumns.push(stitle);
        }
        $(originalJson).each(function (index, item) {
            if (item) {  // for IE bug~ fuck!
                var oneItem = [];
                for (var key in convertor) {
                    oneItem.push(convertor[key](item));
                }
                dataTableData.aaData.push(oneItem);
            }
        });
        return dataTableData;
    }
};
var DataConverterForfullcalendar = {};

DataConverterForfullcalendar = {
    convertfullcalendar: function (leaveInfoListJson, convertor) {
        var leaveInfoList = [];
        $(leaveInfoListJson).each(function (index, item) {
            if (item) {
                var leaveItem = {};
                for (var key in convertor) {
                    leaveItem[key] = convertor[key](item);
                }
                leaveInfoList.push(leaveItem);
            }
        });
        return leaveInfoList;
    }
};
/// DataTable操作方法


// 给DataTable 加一个Title
$.fn.dataTableTitle = function (title) {

    this.each(function () {

		// 移除现有的title
		var existedTitle = $(this).prev();
		if (existedTitle[0] && existedTitle[0].classList[0] == 'tblTitle'){
			existedTitle.remove();
		}
		
		var divTitle = $('<div class="tblTitle"/>')
                          .css({ 'text-align': 'center' })
                          .html(title);
						  
        $(this).parent().prepend(divTitle)
	
    });
};